home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / sossnt.zip / SOSSNT / RPC / AUTH.H < prev    next >
C/C++ Source or Header  |  1993-03-06  |  3KB  |  137 lines

  1. /*    SccsId [] = "@(#)auth.h.u    4.1\t2/5/87"    */
  2. /*      @(#)auth.h 1.1 86/09/24 SMI      */
  3.  
  4. /*
  5.  * auth.h, Authentication interface.
  6.  *
  7.  * Copyright (C) 1984, Sun Microsystems, Inc.
  8.  *
  9.  * The data structures are completely opaque to the client.  The client
  10.  * is required to pass a AUTH * to routines that create rpc
  11.  * "sessions".
  12.  */
  13.  
  14.  
  15. #define MAX_AUTH_BYTES    400
  16.  
  17.  
  18. /*
  19.  * Status returned from authentication check
  20.  */
  21. enum auth_stat {
  22.     AUTH_OK=0,
  23.     /*
  24.      * failed at remote end
  25.      */
  26.     AUTH_BADCRED=1,            /* bogus credentials (seal broken) */
  27.     AUTH_REJECTEDCRED=2,        /* client should begin new session */
  28.     AUTH_BADVERF=3,            /* bogus verifier (seal broken) */
  29.     AUTH_REJECTEDVERF=4,        /* verifier expired or was replayed */
  30.     AUTH_TOOWEAK=5,            /* rejected due to security reasons */
  31.     /*
  32.      * failed locally
  33.     */
  34.     AUTH_INVALIDRESP=6,        /* bogus response verifier */
  35.     AUTH_FAILED=7            /* some unknown reason */
  36. };
  37.  
  38.  
  39. union des_block {
  40.     struct {
  41.         u_long high;
  42.         u_long low;
  43.     } key;
  44.     char c[8];
  45. };
  46.  
  47.  
  48. /*
  49.  * Authentication info.  Opaque to client.
  50.  */
  51. struct opaque_auth {
  52.     enum_t    oa_flavor;        /* flavor of auth */
  53.     caddr_t    oa_base;        /* address of more auth stuff */
  54.     u_int    oa_length;        /* not to exceed MAX_AUTH_BYTES */
  55. };
  56.  
  57.  
  58. /*
  59.  * Auth handle, interface to client side authenticators.
  60.  */
  61. typedef struct {
  62.     struct    opaque_auth    ah_cred;
  63.     struct    opaque_auth    ah_verf;
  64.     union    des_block    ah_key;
  65.     struct auth_ops {
  66.         void    (*ah_nextverf)();
  67.         int    (*ah_marshal)();    /* nextverf & serialize */
  68.         int    (*ah_validate)();    /* validate varifier */
  69.         int    (*ah_refresh)();    /* refresh credentials */
  70.         void    (*ah_destroy)();    /* destroy this structure */
  71.     } *ah_ops;
  72.     caddr_t ah_private;
  73. } AUTH;
  74.  
  75.  
  76. /*
  77.  * Authentication ops.
  78.  * The ops and the auth handle provide the interface to the authenticators.
  79.  *
  80.  * AUTH    *auth;
  81.  * XDR    *xdrs;
  82.  * struct opaque_auth verf;
  83.  */
  84. #define AUTH_NEXTVERF(auth)        \
  85.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  86. #define auth_nextverf(auth)        \
  87.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  88.  
  89. #define AUTH_MARSHALL(auth, xdrs)    \
  90.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  91. #define auth_marshall(auth, xdrs)    \
  92.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  93.  
  94. #define AUTH_VALIDATE(auth, verfp)    \
  95.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  96. #define auth_validate(auth, verfp)    \
  97.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  98.  
  99. #define AUTH_REFRESH(auth)        \
  100.         ((*((auth)->ah_ops->ah_refresh))(auth))
  101. #define auth_refresh(auth)        \
  102.         ((*((auth)->ah_ops->ah_refresh))(auth))
  103.  
  104. #define AUTH_DESTROY(auth)        \
  105.         ((*((auth)->ah_ops->ah_destroy))(auth))
  106. #define auth_destroy(auth)        \
  107.         ((*((auth)->ah_ops->ah_destroy))(auth))
  108.  
  109.  
  110. extern struct opaque_auth _null_auth;
  111.  
  112.  
  113. /*
  114.  * These are the various implementations of client side authenticators.
  115.  */
  116.  
  117. /*
  118.  * Unix style authentication
  119.  * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
  120.  *    char *machname;
  121.  *    int uid;
  122.  *    int gid;
  123.  *    int len;
  124.  *    int *aup_gids;
  125.  */
  126. #ifdef KERNEL
  127. extern AUTH *authkern_create();        /* takes no parameters */
  128. #else
  129. extern AUTH *authunix_create();
  130. extern AUTH *authunix_create_default();    /* takes no parameters */
  131. extern AUTH *authnone_create();        /* takes no parameters */
  132. #endif
  133.  
  134. #define    AUTH_NULL    0
  135. #define    AUTH_UNIX    1        /* unix style (uid, gids) */
  136. #define    AUTH_SHORT    2        /* short hand unix style */
  137.